﻿/// <reference path="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.4.4-vsdoc.js" />

/*
JavaScript functions for the BugReport.aspx page
*/

$(document).ready(function () {

    // setup the validation
    InitValidation();
});

function InitValidation() {

    $("#aspnetForm").validate();
}

function AddAttachmentControl() {

    // get all hidden file upload controls
    var hiddenControls = $('.AttachmentControlHidden');

    // if there is a hidden control, show the first
    if (hiddenControls.length != 0) {
        hiddenControls.first().switchClass('AttachmentControlHidden', 'AttachmentControlVisible', 0);
        $('a[id$=hlAttachmentRemove]:first').show();
    }

    // if there is no hidden file upload control to add, hide the "Add" link
    if ($('.AttachmentControlHidden').length == 0)
        $('a[id$=hlAttachmentAdd]:first').hide();
}

function RemoveAttachmentControl() {

    // get all visible file upload controls
    var visibleControls = $('.AttachmentControlVisible')

    // if there is more than the default visible control, hide the last
    if (visibleControls.length != 1) {
        visibleControls.last().switchClass('AttachmentControlVisible', 'AttachmentControlHidden', 0);
        $('a[id$=hlAttachmentAdd]:first').show();
    }

    // if there is no visible file upload control to remove, hide the "Remove" link
    if ($('.AttachmentControlVisible').length == 1)
        $('a[id$=hlAttachmentRemove]:first').hide();
}